﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly ShopDBContext shopDBContext;
        public IUserRepository Users { get; private set; }
        public IProductRepository Products { get; private set; }
        public IProductCategoryRepository ProductCategories { get; private set; }
        public UnitOfWork(ShopDBContext dbContext)
        {
            shopDBContext = dbContext;
            Users = new UserRepository(dbContext);
            Products = new ProductRepository(dbContext);
            ProductCategories = new ProductCategoryRepository(dbContext);
        }
        public void Commit()
        {
            shopDBContext.SaveChanges();
        }
    }
}
